class EatersController < ApplicationController
  # GET /eaters
  # GET /eaters.xml
  def addEater
    puts hallo
  end
  
  def index
    @eaters = Eater.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @eaters }
    end
  end

  # GET /eaters/1
  # GET /eaters/1.xml
  def show
    @eater = Eater.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @eater }
    end
  end

  # GET /eaters/new
  # GET /eaters/new.xml
  def new
    @eater = Eater.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @eater }
    end
  end

  # GET /eaters/1/edit
  def edit
    @eater = Eater.find(params[:id])
  end

  # POST /eaters
  # POST /eaters.xml
  def create
    @eater = Eater.new(params[:eater])

    respond_to do |format|
      if @eater.save
        flash[:notice] = 'Eater was successfully created.'
        format.html { redirect_to(@eater) }
        format.xml  { render :xml => @eater, :status => :created, :location => @eater }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @eater.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /eaters/1
  # PUT /eaters/1.xml
  def update
    @eater = Eater.find(params[:id])

    #checken of er geen kok staat toegewezen
    respond_to do |format|
      if @eater.update_attributes(params[:eater])
        flash[:notice] = 'Eater was successfully updated.'
        format.html { redirect_to(@eater) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @eater.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /eaters/1
  # DELETE /eaters/1.xml
  def destroy
    @eater = Eater.find(params[:id])
    @dinnermoment = Dinnermoment.find(@eater.dinnermoment_id)
    @eater.destroy

    render :update do |page|
    	page.replace_html "moment#{@dinnermoment.id}", :partial => @dinnermoment
    end
    # respond_to do |format|
    #      format.html { redirect_to(eaters_url) }
    #      format.xml  { head :ok }
    #    end
  end
  
  private

end
